package com.code.leetcode.idea;

public class LeetCodeIdea020 {
    public static void main(String[] args) {
//        String s = "()[]{}";
        String s = "()";
        LeetCodeIdea020 leetCodeIdea020 = new LeetCodeIdea020();
        boolean valid = leetCodeIdea020.isValid(s);
        System.out.println(valid);

    }
    public boolean isValid(String s) {
        while (s.indexOf("()") >= 0 || s.indexOf("[]") >= 0 || s.indexOf("{}") >= 0) {
            s = s.replace("()", "");
            s = s.replace("[]", "");
            s = s.replace("{}", "");
        }
        if (s.length() > 0 ) {
            return false;
        } else {
            return true;
        }
    }
}
